package com.colin.util.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegUtil {
	/**
	 * 手机号
	 */
	private static final String MOBILE_REG = "1[3|4|5|7|8|9][0-9]\\d{8}";
	/**
	 * 身份证
	 */
	private static final String ID_CARD_REG = "";
	/**
	 * 汉字
	 */
	private static final String CHINESE_REG = "^[\\u4e00-\\u9fa5]+(·[\\u4e00-\\u9fa5]+)*$";
	/**
	 * 邮箱
	 */
	private static final String EMAIL_REG = "^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$";

	public static boolean isMobile(String mobiles){
		if( mobiles == null || "".equals(mobiles) ){
			return false;
		}
        Pattern p = Pattern.compile(MOBILE_REG);
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }

	public static boolean isLegalName(String realName) {
		if( realName == null || "".equals(realName) ){
			return false;
		}
		Pattern pattern = Pattern.compile(CHINESE_REG);
		Matcher matcher = pattern.matcher(realName);
		return matcher.matches();
	}
   
    public static boolean isEmail(String email){
		if( email == null || "".equals(email) ){
			return false;
		}
        Pattern p = Pattern.compile(EMAIL_REG);     
        Matcher m = p.matcher(email);     
        return m.matches();     
    } 
	
    
}
